<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>  
<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="Content-Language" content="zh-CN">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="shop">
    <meta name="author" content="letsun">

    <title>消费记录</title>

    <link rel="stylesheet" type="text/css" href="${resources}/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="${resources}/plugs/fontAwesome/4.6.3/css/font-awesome.min.css"/>
    <link rel="stylesheet" type="text/css" href="${resources}/css/jquery.gritter.css">
    <link rel="stylesheet" type="text/css" href="${resources}/css/bootstrap-sticky-footer.css">
    <link rel="stylesheet" type="text/css" href="${resources}/css/bootstrap-fix.css">
    <link rel="stylesheet" type="text/css" href="${resources}/css/foot.css">

    <style>
        .main {
            height: 100%;
        }

        .page-content {
            position: relative;
        }

        .mask {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            z-index: 1;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.5);
            color: #FFF;
            text-align: center;
            padding-top: 50%;
            font-size: 40px;
        }

        .cartPanel {
            width: 100%;
            height: 100px;
            border-bottom: 1px solid #DDD;
            background: #FFF;
        }

        .cartSelect {
            float: left;
            width: 30px;
            height: 100px;
            line-height: 100px;
            font-size: 20px;
        }

        .cartGoods {
            height: 100px;
            margin-left: 30px;
            padding: 10px;
            text-align: left
        }

        .cartGoods img {
            float: left;
            width: 80px;
            height: 80px;
        }

        .itemPrice {
            float: right;
            width: 50px;
            text-align: right;
            font-size: 12px;
        }

        .pricePanel {
            height: 40px;
        }

        .trashPanel {
            height: 40px;
            line-height: 40px;
            font-size: 20px;
            color: #cdcdcd
        }

        .goodInfo {
            margin-left: 80px;
            margin-right: 50px;
            width: auto;
        }

        .goodTitlePanel {
            font-size: 14px;
            line-height: 15px;
            margin: 5px;
            height: 30px;
            overflow: hidden;
        }

        .goodTitlePanel span {
            word-wrap: break-word;
            text-overflow: ellipsis;
            color: #666;
        }

        .goodNum {
            height: 40px;
            padding: 0px 5px;
        }

        .numCont {
            width: 105px;
            height: 26px;
            background: #EEE;
            line-height: 24px;
            border: 1px solid #CCC;
            border-radius: 2px;
        }

        .numAdd {
            width: 32px;
            display: block;
            float: left;
            text-align: center;
            border-right: 1px solid #CCC;
        }

        .numReduction {
            width: 32px;
            display: block;
            float: left;
            text-align: center;
            border-left: 1px solid #CCC;
        }

        .numShow {
            width: 37px;
            display: block;
            float: left;
            text-align: center;
            background: #FFF;
            color: #333
        }

        .payPanel {
            position: fixed;
            bottom: 0px;
            width: 100%;
            height: 50px;
            padding: 5px;
            background: #DDD;
        }

        .radioAll {
            float: left;
            width: 20px;
            height: 50px;
            line-height: 40px;
            font-size: 20px;
        }

        .sumMoney {
            float: left;
            width: auto;
            max-width: 200px;
            height: 50px;
            line-height: 40px;
            font-size: 14px;
        }

        .payBtn {
            display: block;
            float: right;
            width: 120px;
            height: 40px;
            color: #FFF;
            background: #FF6666;
            line-height: 40px;
            border-radius: 20px;
        }

        .shopName {
            padding: 0 40px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        #orderList {
            padding-bottom: 60px;
        }

        .pageBtn {
            position: absolute;
            bottom: 20px;
            border: 1px solid #ccc;
            border-radius: 5px;
            left: 50%;
            -webkit-transform: translate(-50%, 0);
            -moz-transform: translate(-50%, 0);
            -ms-transform: translate(-50%, 0);
            -o-transform: translate(-50%, 0);
            transform: translate(-50%, 0);
        }

        .pageBtn li {
            width: 40px;
            height: 40px;
            float: left;
            border-right: 1px solid #ccc;
            text-align: center;
            line-height: 40px;
        }

        .pageBtn li:last-child {
            border: none;
        }

        .pageBtn .prev, .pageBtn .next {
            width: 60px;
        }
        
        .pageBtn .active{
        	background-color: #2196F3;
        	color: #fff;
        }
    </style>
    <link rel="stylesheet" type="text/css" href="${resources}/css/consumeRecord.css">
    <%@ include file="../init.jsp" %>
    <script src="${resources}/js/jqPaginator.min.js"></script>
    <script src="${resources}/js/moment.js"></script>
</head>

<body>
<%@ include file="../header_1.jsp" %>
<!--- 导航： end -->

<div class="container">
    <div class="row">
        <div class="col-md-1">
        	<%@ include file ="../menu.jsp" %>
        </div>
        <div class="col-md-11">

            <div class="mask">
                <span style="margin:auto;">
                    <i class="fa fa-spinner fa-spin"></i>
                </span>
            </div>

            <div id="orderList">
               
                 
            </div>
        </div>
    </div>
</div>

<%@ include file="../footer.jsp" %>
<!-- footer:页脚  end -->
<script type="text/javascript">
    /**
     * 分页
     * @param cfg
     */
     var selData = ({
 		pageNumber : 1
 	})
    
    function paging(cfg) {
        var paginator = $("#orderList");

        paginator.jqPaginator({
            totalCounts: 500,//总条目数
            pageSize:5,//每一页显示的条目数
            visiblePages: 5,//分多少页
            currentPage: 1,//当前页数
            first: '<li class="first"><a href="javascript:void(0);">首页<\/a><\/li>',
            prev: '<li class="prev"><a href="javascript:void(0);">上一页<\/a><\/li>',
            next: '<li class="next"><a href="javascript:void(0);">下一页<\/a><\/li>',
            last: '<li class="last"><a href="javascript:void(0);">末页<\/a><\/li>',
            page: '<li class="page"><a href="javascript:void(0);">{{page}}<\/a><\/li>',
            wrapper: '<ul class="pageBtn"></ul>',

            //页面加载和点击页码时请求数据
            onPageChange: function (num) {
            	selData.pageNumber= num;
                $.get(cfg.url, selData, function (res) {
                    if (res.msg == 0) {
                        $("#orderList").html('<p style="padding: 20px;color:red;text-align: center">暂无消费记录</p>');
                        return;
                    }
					
                    var html = "";

                    //重新配置分页的总条目数
                    var count = -(res.msg) * (-1);
                    paginator.jqPaginator('option', {
                        totalCounts: count
                    });
                    for (var i = 0; i < res.result.length; i++) {
                    	var itemList = res.result[i].orderItemList;
                    	html += ' <ul class="orderList"><li class="order">';
                    	var ns = moment(res.result[i].order.createTime).format('YYYY-mm-DD, hh:mm:ss');
                   		html += ' <h3 class="title">'+ns+'<span class="shopName">'+res.result[i].order.merchant.name+'</span></h3>';
                  		html += '<ul class="goodsList">';
                  		for (var j = 0; j <itemList.length; j++) {
	               			html += '<li class="goods">';
	           				html += '<div class="goodsImg"><img src="'+itemList[j].goods.picurl+'" alt=""></div>';
	           				html += '<div class="descLeft">';
	           				html += '<h4 class="goodsName">'+itemList[j].goods.name+'</h4>';
	           				html += '<div class="price">'+itemList[j].goods.price+'</div>';
	           				html += '</div>';
	           				html += '<div class="descRight">';
	           				html += '<div class="num">'+itemList[j].amount+'</div>';
	           				html += '<div class="total">合计：'+itemList[j].price+'</div>';
	           				html += '<div class="status">已支付</div>';
	           				html += '</div>';
	           				html += '</li>';
						}
           				html += '</ul>';
           				html += '<div class="detailButton">';
           				html += '<button class="detailBtn" onclick="toInfo('+res.result[i].order.id+')">详情</button>';
           				html += '</div>';
           				html += '</li></ul>';
                    }

                    $("#orderList").append(html);
                });
            }
        });
    }
    paging({url: "${path}/manage/myCenter/shopData"});
</script>
<script type="text/javascript">
	function toInfo(id){
		window.location.href="${path}/manage/myCenter/orderInfo/"+id;
	}
</script>
</body>
</html>